package com.zbkj.client.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zbkj.common.model.client.message.AgentSession;
import com.zbkj.common.model.client.message.Dialog;
import com.zbkj.common.model.client.message.Message;
import com.zbkj.common.request.client.SendMessageRequest;
import com.zbkj.common.response.client.MessageList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

import org.springframework.web.socket.WebSocketSession;

public interface MessageService extends IService<Message> {
    void sendMessage(SendMessageRequest request, HttpServletResponse response, HttpServletRequest httpRequest, Integer userId) throws Exception;
    List<MessageList> getMessageList(Integer dialogId, Integer page, Integer pagesize);

    void sendMessageWebSocket(SendMessageRequest request, Integer userId, String token, WebSocketSession session);

    Integer insertMessage(Map<String, Object> params);

    void chatStream(String agentId, String message, String sessionId, HttpServletResponse response, Map<String, Object> params, String agentSessionId, Map<String, Object> agentUserInfo,Map<String, Object> userLocationInfo);

    void groupChatStream(String groupId, String message, String sessionId, HttpServletResponse response, Map<String, Object> params, String agentSessionId,Map<String, Object> agentUserInfo,Map<String, Object> userLocationInfo);

    /**
     * 创建session会话，先请求调用api接口创建，再创建本地库的sessionId
     * @param sendMessageRequest
     * @return
     */
    AgentSession createSession(SendMessageRequest sendMessageRequest,Integer userId);

    /**
     *
     * 调用api创建sessionId
     * @param paramMap
     * @return
     */
    Map<String, Object> createSessionApi(Map<String, Object> paramMap);

    /**
     * 删除服务端的agentSessionId
     * @param agentSessionId
     * @return
     */
    Map<String, Object> delSessionApi(String agentSessionId);

    /**
     * 返回聊天框成员的头像
     * @param dialogId
     * @param token
     * @return
     */
    Map<String, Object> getDialogImgs(Integer dialogId, String token);

    /**
     * 生成对话框
     * @param request
     * @param userId
     * @return
     */
    Dialog insertDialog(SendMessageRequest request, Integer userId);

    /**
     * 删除Agent会话和相关消息
     * @param request 请求参数
     */
    void delAgentSession(SendMessageRequest request);
}